import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from '@vant/auto-import-resolver'

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [VantResolver()],
    }),
    Components({
      resolvers: [VantResolver()],
    }),
  ],
  server: {
    proxy: {
      '/merchantapi': {
        // target: 'https://demo.qqss.net', // 目标后端地址
        // target: 'https://jangtg.com',
        changeOrigin: true,       // 支持虚拟主机的情况
        secure: false, // 如果是 https 接口，需要设置为 false
        rewrite: (path) => path.replace(/^\/merchantapi/, '') // 去掉前缀
      }
    }
  }
})
